<template>
  <div class="login-phone">
    <el-form :model="phone" :rules="phoneRules" ref="phoneRef">
      <el-form-item label="手机号" label-width="70px" prop="number">
        <el-input v-model="phone.number" type="text"></el-input>
      </el-form-item>
      <el-form-item label="验证码" label-width="70px">
        <div class="code">
          <el-input v-model="phone.code" type="text"></el-input>
          <el-button class="get-code" type="primary">获取验证码</el-button>
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, ref } from "vue"
import { phoneRules } from "../config/account-config"
import { ElForm } from "element-plus"
export default defineComponent({
  setup() {
    const phone = reactive({
      number: "",
      code: "",
    })
    const phoneRef = ref<InstanceType<typeof ElForm>>()

    const actionLogin = () => {
      // 验证手机号
      phoneRef.value?.validate(valid => {
        console.log(valid)
      })
    }

    return {
      phone,
      phoneRules,
      actionLogin,
      phoneRef,
    }
  },
})
</script>
<style lang="less" scoped>
.get-code {
  margin-left: 8px;
}
.code {
  display: flex;
}
</style>
